#!/bin/sh

launchctl unload /Library/LaunchAgents/com.lct.AutoRun.plist
rm -R /Library/Application\ Support/LCTApp
rm -R /Library/LaunchAgents/com.lct.AutoRun.plist

# rmove mode script
rm -R "/Library/Modem Scripts/LJA USB MODEM"

# remove mode application and uninstaller
rm -R "/Users/$USER/Desktop/UX302NC Data Connection Manager"
rm -R "/Users/$USER/Desktop/UX302NC Data Connection Manager.app"
rm -R "/Applications/HSPA USB Modem.app"
rm -R "/Users/$USER/Library/Preferences/P10A_LU1250"

rm -R "/Applications/HSPA USB Modem Uninstall.app"

# ===================================================================================================================

# install modem script
cp -R /tmp/P10ATemp/Library/Modem\ Scripts/LJA\ USB\ MODEM /Library/Modem\ Scripts/LJA\ USB\ MODEM

mkdir /Applications/UX302NC\ Data\ Connection\ Manager

# install application and uninstaller
cp -R /tmp/P10ATemp/Applications/"HSPA USB Modem.app" /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem.app"
chown -R root:admin /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem.app"
chmod -R 775 /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem.app"

cp -R /tmp/P10ATemp/Applications/"HSPA USB Modem Uninstall.app" /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem Uninstall.app"
chown -R root:admin /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem Uninstall.app"
chmod -R 775 /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem Uninstall.app"

cp -R /tmp/P10ATemp/Applications/"HSPA USB Modem.app"/Contents/Resources/options-v4 /private/etc/ppp/options

# create alias
ln -fs /Applications/UX302NC\ Data\ Connection\ Manager/"HSPA USB Modem.app" /Users/$USER/Desktop/"UX302NC Data Connection Manager"

# install auto run app
cp -R /tmp/P10ATemp/Library/Application\ Support/LCTApp /Library/Application\ Support
chown -R root:wheel /Library/Application\ Support/LCTApp/LCTAutoRun
chmod -R 755 /Library/Application\ Support/LCTApp/LCTAutoRun

cp -R /tmp/P10ATemp/Library/LaunchAgents/com.lct.AutoRun.plist /Library/LaunchAgents/com.lct.AutoRun.plist
chown -R root:wheel /Library/LaunchAgents/com.lct.AutoRun.plist
chmod -R 755 /Library/LaunchAgents/com.lct.AutoRun.plist

#launchctl load /Library/LaunchAgents/com.lct.AutoRun.plist

